﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tblAdminDAL : SqlDataProvider
	{

		#region[tblAdmin_GetbyAll]
		public DataTable tblAdmin_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblAdmin_GetbyId]
		public DataTable tblAdmin_GetById(tblAdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_aid", Data._aid));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblAdmin_GetbyTop]
		public DataTable tblAdmin_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tblAdmin_Insert]
		public void tblAdmin_Insert(tblAdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_aname", Data._aname));
				cmd.Parameters.Add(new SqlParameter("@_apassword", Data._apassword));
				cmd.Parameters.Add(new SqlParameter("@_arole", Data._arole));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblAdmin_Update]
		public void tblAdmin_Update(tblAdminInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_aid", Data._aid));
				cmd.Parameters.Add(new SqlParameter("@_aname", Data._aname));
				cmd.Parameters.Add(new SqlParameter("@_apassword", Data._apassword));
				cmd.Parameters.Add(new SqlParameter("@_arole", Data._arole));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tblAdmin_Delete]
		public void tblAdmin_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tblAdmin_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@_aid", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion

   
	}
}